#include "../lib/scicalc.h"
#include <stdio.h>
#include <stdlib.h>

int main() {
    // Example dense matrix
    double dense[3][3] = {
        {1.0, 0.0, 0.0},
        {0.0, 2.0, 0.0},
        {0.0, 0.0, 3.0}
    };
    
    // Convert to sparse format
    int count;
    double* rows[3] = {dense[0], dense[1], dense[2]};
    SparseElement* sparse = dense_to_sparse(rows, 3, 3, &count);
    
    printf("Sparse matrix (count=%d):\n", count);
    for(int i = 0; i < count; i++) {
        printf("(%d,%d) = %.1f\n", sparse[i].row, sparse[i].col, sparse[i].value);
    }
    
    // Convert back to dense format
    double** new_dense = sparse_to_dense(sparse, count, 3, 3);
    
    printf("\nReconstructed dense matrix:\n");
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            printf("%.1f ", new_dense[i][j]);
        }
        printf("\n");
    }
    
    // Clean up
    free(sparse);
    for(int i = 0; i < 3; i++) {
        free(new_dense[i]);
    }
    free(new_dense);
    
    return 0;
}